﻿using System.ComponentModel.DataAnnotations;
using BLL.CustomAttribute;

namespace BLL.Model.Menu
{
    public class MenuInfo
    {
        public MenuInfo()
        {
            OpenNewWindow = false;
            Order = int.MaxValue;
        }

        [Key, StringProperty]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        [Display(Name = "显示名称")]
        [StringLength(20), StringProperty, Required(AllowEmptyStrings = false)]
        public string Name { get; set; }

        private string _href;
        [Display(Name = "链接地址")]
        [StringLength(2000), StringProperty, Required(AllowEmptyStrings = false)]
        public string Href
        {
            get { return _href; }
            set
            {
                if (!value.Trim().StartsWith("http://") && !value.Trim().StartsWith("https://"))
                {
                    value = "http://" + value;
                }
                _href = value;
            }
        }

        [Display(Name = "排序")]
        public int Order { get; set; }

        [Display(Name = "在新窗口打开")]
        public bool OpenNewWindow { get; set; }

    }
}